package org.example.data_work_demo1.service;
// AdminService.java


import org.example.data_work_demo1.mapper.AdminMapper;
import org.example.data_work_demo1.model.Admin;
import org.example.data_work_demo1.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AdminService {

    @Autowired
    private AdminMapper adminMapper;

    // 管理员登录
    public Admin login(String username, String password) {
        return adminMapper.login(username, password);
    }

    // 添加管理员
    public void addAdmin(Admin admin) {
        adminMapper.addAdmin(admin);
    }

    // 删除管理员
    public void deleteAdmin(Integer adminId) {
        adminMapper.deleteAdmin(adminId);
    }

    // 更新管理员信息
    public void updateAdmin(Admin admin) {
        adminMapper.updateAdmin(admin);
    }

    // 添加用户
    public void addUser(User user) {
        adminMapper.addUser(user);
    }

    // 删除用户
    public void deleteUser(Integer userId) {
        adminMapper.deleteUser(userId);
    }

    // 更新用户信息
    public void updateUser(User user) {
        adminMapper.updateUser(user);
    }

    // 查询用户详情
    public User queryUser(Integer userId) {
        return adminMapper.queryUser(userId);
    }
    // 查询所有用户
    public List<User> getUsers() {
        return adminMapper.getUsers();
    }
    //  查询所有管理员
    public List<Admin> getAllAdmins() {
        return adminMapper.getAdmins();
    }
}
